package o;

import java.io.Closeable;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.IDN;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.security.KeyStore;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import o.fui.a;

public final class fvg {
    public static final Comparator<String> ʻ = new Comparator<String>() {
        public /* synthetic */ int compare(Object obj, Object obj2) {
            return ˏ((String) obj, (String) obj2);
        }

        public int ˏ(String str, String str2) {
            return str.compareTo(str2);
        }
    };
    private static final Charset ʻॱ = Charset.forName("UTF-32BE");
    public static final Charset ʼ = Charset.forName("ISO-8859-1");
    private static final Pattern ʼॱ = Pattern.compile("^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$");
    private static final fxh ʽ = fxh.ˋ("efbbbf");
    private static final Pattern ʿ = Pattern.compile("^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$");
    public static final byte[] ˊ = new byte[0];
    private static final fxh ˊॱ = fxh.ˋ("ffff0000");
    public static final String[] ˋ = new String[0];
    private static final fxh ˋॱ = fxh.ˋ("fffe");
    public static final Charset ˎ = Charset.forName("UTF-8");
    public static final fuw ˏ;
    private static final Charset ˏॱ = Charset.forName("UTF-16LE");
    private static final fxh ͺ = fxh.ˋ("0000ffff");
    public static final fuy ॱ;
    private static final Charset ॱˊ = Charset.forName("UTF-16BE");
    private static final Charset ॱˋ = Charset.forName("UTF-32LE");
    private static final Method ॱˎ;
    public static final TimeZone ॱॱ = TimeZone.getTimeZone("GMT");
    private static final Pattern ॱᐝ = Pattern.compile("^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$");
    private static final fxh ᐝ = fxh.ˋ("feff");
    private static final Pattern ᐝॱ = Pattern.compile("([0-9a-fA-F]*:[0-9a-fA-F:.]*)|([\\d.]+)");

    class AnonymousClass4 implements ThreadFactory {
        final /* synthetic */ boolean ˊ;
        final /* synthetic */ String ˎ;

        AnonymousClass4(String str, boolean z) {
            this.ˎ = str;
            this.ˊ = z;
        }

        public Thread newThread(Runnable runnable) {
            Thread thread = new Thread(runnable, this.ˎ);
            thread.setDaemon(this.ˊ);
            return thread;
        }
    }

    public static boolean ˎ(o.fxw r12, int r13, java.util.concurrent.TimeUnit r14) throws java.io.IOException {
        /* JADX: method processing error */
/*
Error: jadx.core.utils.exceptions.JadxRuntimeException: Can't find block by offset: 0x006a in list []
	at jadx.core.utils.BlockUtils.getBlockByOffset(BlockUtils.java:42)
	at jadx.core.dex.instructions.IfNode.initBlocks(IfNode.java:60)
	at jadx.core.dex.visitors.blocksmaker.BlockFinish.initBlocksInIfNodes(BlockFinish.java:48)
	at jadx.core.dex.visitors.blocksmaker.BlockFinish.visit(BlockFinish.java:33)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:31)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:17)
	at jadx.core.ProcessClass.process(ProcessClass.java:37)
	at jadx.core.ProcessClass.processDependencies(ProcessClass.java:59)
	at jadx.core.ProcessClass.process(ProcessClass.java:42)
	at jadx.api.JadxDecompiler.processClass(JadxDecompiler.java:306)
	at jadx.api.JavaClass.decompile(JavaClass.java:62)
*/
        /*
        r2 = 9223372036854775807; // 0x7fffffffffffffff float:NaN double:NaN;
        r6 = java.lang.System.nanoTime();
        r0 = r12.ˊ();
        r0 = r0.at_();
        if (r0 == 0) goto L_0x0051;
    L_0x0013:
        r0 = r12.ˊ();
        r0 = r0.ˏ();
        r0 = r0 - r6;
    L_0x001c:
        r4 = r12.ˊ();
        r8 = (long) r13;
        r8 = r14.toNanos(r8);
        r8 = java.lang.Math.min(r0, r8);
        r8 = r8 + r6;
        r4.ˋ(r8);
        r4 = new o.fxi;	 Catch:{ InterruptedIOException -> 0x0042, all -> 0x0073 }
        r4.<init>();	 Catch:{ InterruptedIOException -> 0x0042, all -> 0x0073 }
    L_0x0032:
        r8 = 8192; // 0x2000 float:1.14794E-41 double:4.0474E-320;	 Catch:{ InterruptedIOException -> 0x0042, all -> 0x0073 }
        r8 = r12.ˊ(r4, r8);	 Catch:{ InterruptedIOException -> 0x0042, all -> 0x0073 }
        r10 = -1;	 Catch:{ InterruptedIOException -> 0x0042, all -> 0x0073 }
        r5 = (r8 > r10 ? 1 : (r8 == r10 ? 0 : -1));	 Catch:{ InterruptedIOException -> 0x0042, all -> 0x0073 }
        if (r5 == 0) goto L_0x0053;	 Catch:{ InterruptedIOException -> 0x0042, all -> 0x0073 }
    L_0x003e:
        r4.ʿ();	 Catch:{ InterruptedIOException -> 0x0042, all -> 0x0073 }
        goto L_0x0032;
    L_0x0042:
        r4 = move-exception;
        r4 = 0;
        r2 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1));
        if (r2 != 0) goto L_0x006a;
    L_0x0048:
        r0 = r12.ˊ();
        r0.ॱॱ();
    L_0x004f:
        r0 = r4;
    L_0x0050:
        return r0;
    L_0x0051:
        r0 = r2;
        goto L_0x001c;
    L_0x0053:
        r4 = 1;
        r2 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1));
        if (r2 != 0) goto L_0x0061;
    L_0x0058:
        r0 = r12.ˊ();
        r0.ॱॱ();
    L_0x005f:
        r0 = r4;
        goto L_0x0050;
    L_0x0061:
        r2 = r12.ˊ();
        r0 = r0 + r6;
        r2.ˋ(r0);
        goto L_0x005f;
    L_0x006a:
        r2 = r12.ˊ();
        r0 = r0 + r6;
        r2.ˋ(r0);
        goto L_0x004f;
    L_0x0073:
        r4 = move-exception;
        r2 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1));
        if (r2 != 0) goto L_0x0080;
    L_0x0078:
        r0 = r12.ˊ();
        r0.ॱॱ();
    L_0x007f:
        throw r4;
    L_0x0080:
        r2 = r12.ˊ();
        r0 = r0 + r6;
        r2.ˋ(r0);
        goto L_0x007f;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.fvg.ˎ(o.fxw, int, java.util.concurrent.TimeUnit):boolean");
    }

    static {
        Method method = null;
        ॱ = fuy.ˎ(method, ˊ);
        ˏ = fuw.create((fup) method, ˊ);
        try {
            method = Throwable.class.getDeclaredMethod("addSuppressed", new Class[]{Throwable.class});
        } catch (Exception e) {
        }
        ॱˎ = method;
    }

    public static void ˋ(Throwable th, Throwable th2) {
        if (ॱˎ != null) {
            try {
                ॱˎ.invoke(th, new Object[]{th2});
            } catch (InvocationTargetException e) {
            } catch (IllegalAccessException e2) {
            }
        }
    }

    public static void ˎ(long j, long j2, long j3) {
        if ((j2 | j3) < 0 || j2 > j || j - j2 < j3) {
            throw new ArrayIndexOutOfBoundsException();
        }
    }

    public static boolean ॱ(Object obj, Object obj2) {
        return obj == obj2 || (obj != null && obj.equals(obj2));
    }

    public static void ॱ(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (IncompatibleClassChangeError e) {
                if (closeable instanceof Socket) {
                    ˎ((Socket) closeable);
                    return;
                }
                throw e;
            } catch (RuntimeException e2) {
                throw e2;
            } catch (Exception e3) {
            }
        }
    }

    public static void ˎ(Socket socket) {
        if (socket != null) {
            try {
                socket.close();
            } catch (AssertionError e) {
                if (!ˎ(e)) {
                    throw e;
                }
            } catch (RuntimeException e2) {
                throw e2;
            } catch (Exception e3) {
            }
        }
    }

    public static boolean ˋ(fxw o_fxw, int i, TimeUnit timeUnit) {
        try {
            return ˎ(o_fxw, i, timeUnit);
        } catch (IOException e) {
            return false;
        }
    }

    public static <T> List<T> ˏ(List<T> list) {
        return Collections.unmodifiableList(new ArrayList(list));
    }

    public static <K, V> Map<K, V> ˎ(Map<K, V> map) {
        if (map.isEmpty()) {
            return Collections.emptyMap();
        }
        return Collections.unmodifiableMap(new LinkedHashMap(map));
    }

    public static <T> List<T> ˋ(T... tArr) {
        return Collections.unmodifiableList(Arrays.asList((Object[]) tArr.clone()));
    }

    public static ThreadFactory ˊ(String str, boolean z) {
        return new AnonymousClass4(str, z);
    }

    public static String[] ˊ(Comparator<? super String> comparator, String[] strArr, String[] strArr2) {
        List arrayList = new ArrayList();
        for (Object obj : strArr) {
            for (Object compare : strArr2) {
                if (comparator.compare(obj, compare) == 0) {
                    arrayList.add(obj);
                    break;
                }
            }
        }
        return (String[]) arrayList.toArray(new String[arrayList.size()]);
    }

    public static boolean ˎ(Comparator<String> comparator, String[] strArr, String[] strArr2) {
        if (strArr == null || strArr2 == null || strArr.length == 0 || strArr2.length == 0) {
            return false;
        }
        for (Object obj : strArr) {
            for (Object compare : strArr2) {
                if (comparator.compare(obj, compare) == 0) {
                    return true;
                }
            }
        }
        return false;
    }

    public static String ॱ(fur o_fur, boolean z) {
        String str;
        if (o_fur.ʻ().contains(":")) {
            str = "[" + o_fur.ʻ() + "]";
        } else {
            str = o_fur.ʻ();
        }
        if (z || o_fur.ॱॱ() != fur.ˎ(o_fur.ˋ())) {
            return str + ":" + o_fur.ॱॱ();
        }
        return str;
    }

    public static boolean ˎ(AssertionError assertionError) {
        return (assertionError.getCause() == null || assertionError.getMessage() == null || !assertionError.getMessage().contains("getsockname failed")) ? false : true;
    }

    public static int ˏ(Comparator<String> comparator, String[] strArr, String str) {
        int length = strArr.length;
        for (int i = 0; i < length; i++) {
            if (comparator.compare(strArr[i], str) == 0) {
                return i;
            }
        }
        return -1;
    }

    public static String[] ॱ(String[] strArr, String str) {
        Object obj = new String[(strArr.length + 1)];
        System.arraycopy(strArr, 0, obj, 0, strArr.length);
        obj[obj.length - 1] = str;
        return obj;
    }

    public static int ˏ(String str, int i, int i2) {
        int i3 = i;
        while (i3 < i2) {
            switch (str.charAt(i3)) {
                case '\t':
                case '\n':
                case '\f':
                case '\r':
                case ' ':
                    i3++;
                default:
                    return i3;
            }
        }
        return i2;
    }

    public static int ˋ(String str, int i, int i2) {
        int i3 = i2 - 1;
        while (i3 >= i) {
            switch (str.charAt(i3)) {
                case '\t':
                case '\n':
                case '\f':
                case '\r':
                case ' ':
                    i3--;
                default:
                    return i3 + 1;
            }
        }
        return i;
    }

    public static String ˎ(String str, int i, int i2) {
        int ˏ = ˏ(str, i, i2);
        return str.substring(ˏ, ˋ(str, ˏ, i2));
    }

    public static int ॱ(String str, int i, int i2, String str2) {
        for (int i3 = i; i3 < i2; i3++) {
            if (str2.indexOf(str.charAt(i3)) != -1) {
                return i3;
            }
        }
        return i2;
    }

    public static int ˊ(String str, int i, int i2, char c) {
        for (int i3 = i; i3 < i2; i3++) {
            if (str.charAt(i3) == c) {
                return i3;
            }
        }
        return i2;
    }

    public static String ˏ(String str) {
        if (str.contains(":")) {
            InetAddress ˊ;
            if (str.startsWith("[") && str.endsWith("]")) {
                ˊ = ˊ(str, 1, str.length() - 1);
            } else {
                ˊ = ˊ(str, 0, str.length());
            }
            if (ˊ == null) {
                return null;
            }
            byte[] address = ˊ.getAddress();
            if (address.length == 16) {
                return ˏ(address);
            }
            throw new AssertionError("Invalid IPv6 address: '" + str + "'");
        }
        try {
            String toLowerCase = IDN.toASCII(str).toLowerCase(Locale.US);
            if (toLowerCase.isEmpty() || ˊ(toLowerCase)) {
                return null;
            }
            return toLowerCase;
        } catch (IllegalArgumentException e) {
            return null;
        }
    }

    private static boolean ˊ(String str) {
        for (int i = 0; i < str.length(); i++) {
            char charAt = str.charAt(i);
            if (charAt <= '\u001f' || charAt >= '') {
                return true;
            }
            if (" #%/:?@[\\]".indexOf(charAt) != -1) {
                return true;
            }
        }
        return false;
    }

    public static int ˋ(String str) {
        int i = 0;
        int length = str.length();
        while (i < length) {
            char charAt = str.charAt(i);
            if (charAt <= '\u001f' || charAt >= '') {
                return i;
            }
            i++;
        }
        return -1;
    }

    public static boolean ॱ(String str) {
        return ᐝॱ.matcher(str).matches();
    }

    public static String ˊ(String str, Object... objArr) {
        return String.format(Locale.US, str, objArr);
    }

    public static Charset ˎ(fxg o_fxg, Charset charset) throws IOException {
        if (o_fxg.ˋ(0, ʽ)) {
            o_fxg.ʼ((long) ʽ.ʼ());
            return ˎ;
        } else if (o_fxg.ˋ(0, ᐝ)) {
            o_fxg.ʼ((long) ᐝ.ʼ());
            return ॱˊ;
        } else if (o_fxg.ˋ(0, ˋॱ)) {
            o_fxg.ʼ((long) ˋॱ.ʼ());
            return ˏॱ;
        } else if (o_fxg.ˋ(0, ͺ)) {
            o_fxg.ʼ((long) ͺ.ʼ());
            return ʻॱ;
        } else if (!o_fxg.ˋ(0, ˊॱ)) {
            return charset;
        } else {
            o_fxg.ʼ((long) ˊॱ.ʼ());
            return ॱˋ;
        }
    }

    public static int ˎ(String str, long j, TimeUnit timeUnit) {
        if (j < 0) {
            throw new IllegalArgumentException(str + " < 0");
        } else if (timeUnit == null) {
            throw new NullPointerException("unit == null");
        } else {
            long toMillis = timeUnit.toMillis(j);
            if (toMillis > 2147483647L) {
                throw new IllegalArgumentException(str + " too large.");
            } else if (toMillis != 0 || j <= 0) {
                return (int) toMillis;
            } else {
                throw new IllegalArgumentException(str + " too small.");
            }
        }
    }

    public static AssertionError ॱ(String str, Exception exception) {
        AssertionError assertionError = new AssertionError(str);
        try {
            assertionError.initCause(exception);
        } catch (IllegalStateException e) {
        }
        return assertionError;
    }

    public static int ˊ(char c) {
        if (c >= '0' && c <= '9') {
            return c - 48;
        }
        if (c >= 'a' && c <= 'f') {
            return (c - 97) + 10;
        }
        if (c < 'A' || c > 'F') {
            return -1;
        }
        return (c - 65) + 10;
    }

    @Nullable
    private static InetAddress ˊ(String str, int i, int i2) {
        Object obj = new byte[16];
        int i3 = i;
        int i4 = -1;
        int i5 = -1;
        int i6 = 0;
        while (i3 < i2) {
            if (i6 == obj.length) {
                return null;
            }
            int ˊ;
            if (i3 + 2 > i2 || !str.regionMatches(i3, "::", 0, 2)) {
                if (i6 != 0) {
                    if (str.regionMatches(i3, ":", 0, 1)) {
                        i3++;
                    } else if (!str.regionMatches(i3, ".", 0, 1)) {
                        return null;
                    } else {
                        if (!ˊ(str, i4, i2, obj, i6 - 2)) {
                            return null;
                        }
                        i6 += 2;
                    }
                }
            } else if (i5 != -1) {
                return null;
            } else {
                i3 += 2;
                i5 = i6 + 2;
                if (i3 == i2) {
                    i6 = i5;
                    break;
                }
                i6 = i5;
            }
            i4 = 0;
            int i7 = i3;
            while (i7 < i2) {
                ˊ = ˊ(str.charAt(i7));
                if (ˊ == -1) {
                    break;
                }
                i4 = (i4 << 4) + ˊ;
                i7++;
            }
            ˊ = i7 - i3;
            if (ˊ == 0 || ˊ > 4) {
                return null;
            }
            ˊ = i6 + 1;
            obj[i6] = (byte) ((i4 >>> 8) & 255);
            i6 = ˊ + 1;
            obj[ˊ] = (byte) (i4 & 255);
            i4 = i3;
            i3 = i7;
        }
        if (i6 != obj.length) {
            if (i5 == -1) {
                return null;
            }
            System.arraycopy(obj, i5, obj, obj.length - (i6 - i5), i6 - i5);
            Arrays.fill(obj, i5, (obj.length - i6) + i5, (byte) 0);
        }
        try {
            return InetAddress.getByAddress(obj);
        } catch (UnknownHostException e) {
            throw new AssertionError();
        }
    }

    private static boolean ˊ(String str, int i, int i2, byte[] bArr, int i3) {
        int i4 = i;
        int i5 = i3;
        while (i4 < i2) {
            if (i5 == bArr.length) {
                return false;
            }
            if (i5 != i3) {
                if (str.charAt(i4) != '.') {
                    return false;
                }
                i4++;
            }
            int i6 = 0;
            int i7 = i4;
            while (i7 < i2) {
                char charAt = str.charAt(i7);
                if (charAt < '0' || charAt > '9') {
                    break;
                } else if (i6 == 0 && i4 != i7) {
                    return false;
                } else {
                    i6 = ((i6 * 10) + charAt) - 48;
                    if (i6 > 255) {
                        return false;
                    }
                    i7++;
                }
            }
            if (i7 - i4 == 0) {
                return false;
            }
            i4 = i5 + 1;
            bArr[i5] = (byte) i6;
            i5 = i4;
            i4 = i7;
        }
        if (i5 != i3 + 4) {
            return false;
        }
        return true;
    }

    private static String ˏ(byte[] bArr) {
        int i = 0;
        int i2 = 0;
        int i3 = -1;
        int i4 = 0;
        while (i4 < bArr.length) {
            int i5 = i4;
            while (i5 < 16 && bArr[i5] == (byte) 0 && bArr[i5 + 1] == (byte) 0) {
                i5 += 2;
            }
            int i6 = i5 - i4;
            if (i6 > i2 && i6 >= 4) {
                i2 = i6;
                i3 = i4;
            }
            i4 = i5 + 2;
        }
        fxi o_fxi = new fxi();
        while (i < bArr.length) {
            if (i == i3) {
                o_fxi.ˊ(58);
                i += i2;
                if (i == 16) {
                    o_fxi.ˊ(58);
                }
            } else {
                if (i > 0) {
                    o_fxi.ˊ(58);
                }
                o_fxi.ʻ((long) (((bArr[i] & 255) << 8) | (bArr[i + 1] & 255)));
                i += 2;
            }
        }
        return o_fxi.ॱᐝ();
    }

    public static X509TrustManager ॱ() {
        try {
            TrustManagerFactory instance = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            instance.init((KeyStore) null);
            TrustManager[] trustManagers = instance.getTrustManagers();
            if (trustManagers.length == 1 && (trustManagers[0] instanceof X509TrustManager)) {
                return (X509TrustManager) trustManagers[0];
            }
            throw new IllegalStateException("Unexpected default trust managers:" + Arrays.toString(trustManagers));
        } catch (Exception e) {
            throw ॱ("No System TLS", e);
        }
    }

    public static fui ˊ(List<fwb> list) {
        a aVar = new a();
        for (fwb o_fwb : list) {
            fux.ˏ.ˋ(aVar, o_fwb.ॱॱ.ˊ(), o_fwb.ᐝ.ˊ());
        }
        return aVar.ˊ();
    }
}
